//
//  WYBaseNavigationController.swift
//  weibo
//
//  Created by 王玉东 on 16/4/8.
//  Copyright © 2016年 wyd. All rights reserved.
//

import UIKit

class WYBaseNavigationController: UINavigationController,UIGestureRecognizerDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.interactivePopGestureRecognizer?.delegate = self
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if self.childViewControllers.count > 0 {
        
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", NImage: "navigationbar_back_withtext", target: self, action: "back")
        
            viewController.hidesBottomBarWhenPushed = true
        }
        
    
        super.pushViewController(viewController, animated: animated)
        
    }
    @objc private func back(){
    popViewControllerAnimated(true)
    }
    
    
    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        
        return childViewControllers.count != 1
    }

}
